import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import Userinfo from '@/components/Userinfo'
import MyOrder from '@/components/MyOrder'
import OrderDetail from '@/components/OrderDetail'
import Submit from '@/components/Submit'
import Success from '@/components/Success'
import constants from './constants'

Vue.use(Router)

const router = new Router({
  routes: [{
    path: '/',
    name: 'Userinfo',
    component: reslove => require(['../components/Userinfo'], reslove)
  },{
    path: '/MyOrder',
    name: 'MyOrder',
    props: {name: 'garrett'},
    component: reslove => require(['../components/MyOrder'], reslove)
  },{
    path: '/OrderDetail',
    name: 'OrderDetail',
    component: reslove => require(['../components/OrderDetail'], reslove)
  },{
    path: '/Submit',
    name: 'Submit',
    component: reslove => require(['../components/Submit'], reslove)
  },{
    path: '/Success',
    name: 'Success',
    component: reslove => require(['../components/Success'], reslove)
  }]
})
//导航后置守卫，可以在确定导航到目标页面时再更改title
router.afterEach((to, from) => {
  window.document.title = constants[to.name];
})

export default router;
